/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.view.crud.tableModels;

import java.util.List;
import systole.domain.report.template.Comparative;

/**
 *
 * @author jmj
 */
public class ComparativeTableModel extends SystoleTableModel<Comparative> {

    private String[] columnNames = {"Nombre", "Observación"};
    private static final int NAME_INDEX = 0;
    private static final int OBSERVATION_INDEX = 1;

    /**
     *
     * @param comparatives
     */
    public ComparativeTableModel(List<Comparative> comparatives) {
        super(comparatives);
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getColumnClass(int)
     */
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case NAME_INDEX:
                return String.class;
            case OBSERVATION_INDEX:
                return String.class;
        }
        return null;
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getColumnCount()
     */
    @Override
    public int getColumnCount() {
        return this.columnNames.length;
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getColumnName(int)
     */
    @Override
    public String getColumnName(int columnIndex) {
        return this.columnNames[columnIndex];
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getValueAt(int, int)
     */
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case NAME_INDEX:
                return this.entities.get(rowIndex).getName();
            case OBSERVATION_INDEX:
                return this.entities.get(rowIndex).getDescription();
        }
        return null;
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
     */
    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case NAME_INDEX:
                this.entities.get(rowIndex).setName((String) aValue);
                break;
            case OBSERVATION_INDEX:
                this.entities.get(rowIndex).setDescription((String) aValue);
                break;
        }
    }
}
